package com.jch.Dao;

import com.entity.Comment;
import com.entity.Movie;
import com.entity.Ticket;
import com.entity.User;

import java.util.List;

public class TicketDao extends BaseDao {

    public List<Ticket> queryTicket(){
        String sql="select * from ticket";

        return findList(Ticket.class,sql);
    }

    public Ticket queryTicket(Object...params){
        String sql="select * from ticket where uid=?";

        return findBean(Ticket.class,sql,params);

    }

    public int insertTicket(Ticket ticket) {
        String sql = "insert into ticket values(null,?,?,?)";
        Object[] params = {ticket.getUid(),ticket.getSid(),ticket.getSeat()};
        return update(sql, params);
    }

    public int[] insertTicketBatch(Object[][] params) {
        String sql = "insert into ticket values(null,?,?,?)";
        return batch(sql, params);
    }

    public List<Ticket> queryTicket2(Object...params){
        String sql="SELECT * FROM ticket where uid=?";

        return findList(Ticket.class,sql,params);

    }

    public int deleteTicket(int id) {
        String sql = "delete from ticket where tid=?";
        Object[] params = {id};
        return update(sql, params);
    }
}
